package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.yingbao.entity.UserMoneyLog;
import cn.stylefeng.guns.modular.yingbao.model.params.UserMoneyLogParam;
import cn.stylefeng.guns.modular.yingbao.service.UserMoneyLogService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 金额流水控制器
 *
 * @author jj
 * @Date 2019-12-11 14:48:51
 */
@Api(tags = "可用余额流水")
@Controller
@CrossOrigin
@RequestMapping("/userMoneyLog")
public class UserMoneyLogController extends BaseController {

    private String PREFIX = "/userMoneyLog";

    @Autowired
    private UserMoneyLogService userMoneyLogService;

    /**
     * 跳转到主页面
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/userMoneyLog.html";
    }

    /**
     * 新增页面
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/userMoneyLog_add.html";
    }

    /**
     * 编辑页面
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/userMoneyLog_edit.html";
    }

    /**
     * 新增接口
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(UserMoneyLogParam userMoneyLogParam) {
        this.userMoneyLogService.add(userMoneyLogParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(UserMoneyLogParam userMoneyLogParam) {
        this.userMoneyLogService.update(userMoneyLogParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(UserMoneyLogParam userMoneyLogParam) {
        this.userMoneyLogService.delete(userMoneyLogParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author jj
     * @Date 2019-12-11
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(UserMoneyLogParam userMoneyLogParam) {
        UserMoneyLog detail = this.userMoneyLogService.getById(userMoneyLogParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author jj
     * @Date 2019-12-11
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(UserMoneyLogParam userMoneyLogParam) {
        return this.userMoneyLogService.findPageBySpec(userMoneyLogParam);
    }

    /**
     * 查询列表
     *
     * @author jj
     * @Date 2019-12-11
     */
    @ApiOperation("可用余额流水")
    @ResponseBody
    @RequestMapping(value = "/appList" ,method = RequestMethod.POST)
    public ResponseData appList(Long userid,int pageNum ,int pageSize) {
        return this.userMoneyLogService.appList(userid,pageNum,pageSize);
    }


}


